
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.game.GameCanvas;

public class Splash extends GameCanvas {

    public Splash() {
        super(false);
        setFullScreenMode(true);
    }

    public void play() {
        try {
            Graphics g = getGraphics();
            Font font = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_PLAIN,
                    Font.SIZE_SMALL);

            g.setFont(font);

            String tw = "Antonio Diego";

            long fps = 45;

            int cx = getWidth();
            int y = (getHeight() - (font.getHeight() * 2)) / 2;

            int v = 4;

            while (v == 4 || v == -4 && cx < (getWidth() - font.stringWidth(tw)) / 2) {
                long startTime = System.currentTimeMillis();

                g.setColor(0);
                g.setColor(0);
                g.fillRect(0, 0, getWidth(), getHeight());

                g.setColor(0x00ff50);

                g.drawString(tw, cx, y, 0);

                flushGraphics();

                cx -= v;

                if (cx < 4) {
                    v = -4;
                }

                long elapsedTime = System.currentTimeMillis() - startTime;

                if (elapsedTime < 1000 / fps) {
                    synchronized (this) {
                        Thread.sleep((1000 / fps - elapsedTime));
                    }
                } else {
                    Thread.yield();
                }
            }

            Thread.sleep(2000);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
